#include<stdio.h>
#include<string.h>
int main()
{
    int t, i;
    scanf("%d", &t);
    char s[10000];
    for (i = 0; i < t; i++)
    {
        memset(s, 0, sizeof(s));
        int n, j = 0, k = 0, m = 0;
        scanf("%d%s", &n,s);
        for (j = 0; j < n; j++)
        {
            if (s[j] == 'y')
            {
                for (k = j + 1; k < n; k++)
                {
                    if (s[k] != 'b')
                        break;
                    if (s[k] == 'b'&&s[k+1]=='b')
                        m++;
                }
            }
        }
        printf("%d\n", m);
    }
    return 0;
}